package com.demo.service.impl;

import com.demo.dao.UserDao;
import com.demo.pojo.User;
import com.demo.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Classname UserServiceImpl
 * @Description TODO
 * @Date 2021/3/15 22:35
 * @Created by 张斌
 */
@Service
public class UserServiceImpl implements UserService {
    private static final Logger logger = LoggerFactory.getLogger(UserServiceImpl.class);
    @Autowired
    private UserDao userDao;
    @Override
    public List<User> getAllUserInfo() {
        List<User> list=userDao.getAllUserInfo();
        if(null!=list){
            logger.info("获取所有的用户信息");

        }else{
            logger.info("获取用户信息失败");
        }

        return list;
    }

    @Override
    @Cacheable(value = "user", key = "#person.id")
    public User getUserInfo(int id) {
        User user=userDao.getUserInfo(id);
        if(null!=user){
            logger.info("获取所有的用户信息");

        }else{
            logger.info("获取用户信息失败");
        }
        return user;
    }

    @Override
    public int addUser(User info) {
        return 0;
    }

    @Override
    public int deleteUser(int id) {
        return 0;
    }
}
